/**
 * Created by vincent on 2017/9/21.
 */
moduleStudyMap.controller("AddTaskStudyController", function ($$CambioConfig, $scope, $log, $state, LoadingService, EnumService,
                                                              UploadFileService, ConstantService, StudyClassResource, DialogService) {
    $scope.$on("ngDialog.opened", function () {
        dialogOnLoad();
    });

    $scope.newTaskStudy = {
        active: true,
        required: true,
        isApprove: true
    };

    $scope.cancel = function () {
        DialogService.close();
    };

    $scope.submit = function () {
        if ($scope.addTSForm.$valid) {
            //LoadingService.show();
            StudyClassResource.setTask({studyClassId: $scope.currentStudyClassId}, $scope.newTaskStudy, function (taskStudyClassResult) {
                $log.debug("课程任务新增结果", taskStudyClassResult);
                angular.copy(taskStudyClassResult, $scope.currentTaskStudyClass);
                DialogService.close();
                Alert.success("新增任务成功！");
                //LoadingService.hide();
            });
        }
    };

});